package com.example.service.impl;

import com.example.dao.OrderDao;
import com.example.entity.Order;
import com.example.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderDao orderDao;

    @Override
    public Integer createOrder(String userId, Integer shopId) {
        // 实现逻辑
        return null;
    }

    @Override
    public Order getOrderById(Integer orderId) {
        return orderDao.getOrderById(orderId);
    }

    @Override
    public List<Order> listOrderByUserId(String userId) {
        return orderDao.listOrderByUserId(userId);
    }

    @Override
    public Integer payOrder(Integer orderId) {
        Order order = orderDao.getOrderById(orderId);
        if (order != null) {
            order.setOrderState(1);
            return orderDao.updateOrder(order);
        }
        return 0;
    }
}